/*
package org.itboys.mobile.controller.weixin;

import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.itboys.commons.CommonConstants;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.mobile.common.SundayCommonConstants;
import org.itboys.mobile.dto.*;
import org.itboys.mobile.entity.mongo.SundayCommunityDynamic;
import org.itboys.mobile.service.mongo.front.SundayFrontCommentService;
import org.itboys.mobile.service.mongo.front.SundayFrontCommunityDynamicService;
import org.itboys.mobile.service.mongo.front.SundayFrontPraiseRecordService;
import org.itboys.mobile.util.AccountIdHoldUtils;
import org.itboys.mobile.util.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

*/
/**
 * Created by zhangyang on 2018/1/8.
 * 圣代_社区_controller_weixin
 *//*

@Controller
@RequestMapping("/sunday/weixin/community")
public class SundayWeiXinCommunityDynamicController extends BaseController{

    @Autowired
    private SundayFrontCommunityDynamicService communityDynamicService;
    @Autowired
    private SundayFrontPraiseRecordService praiseRecordService;
    @Autowired
    private SundayFrontCommentService commentService;


    */
/**
     * 社区:微信圈/本地爱购/达人试用/特别关注等页面
     * @param request
     * @param model
     * @param memberIds 用户id集合,例如:memberIds=1,2,3,4...
     * @param type  类别:1-微信圈,2-达人试用,3-本地爱购,4-特别关注
     * @param memberId  登录用户id
     * @return
     *//*

    @RequestMapping(value="/index", method= RequestMethod.GET)
    public String index(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model,
            @RequestParam(value = "memberIds", required = false)String memberIds,
            @RequestParam(value = "type", required = true)Integer type,
            @RequestParam(value = "memberId", required = false)Long memberId){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            SundayCommunityDataDto dataDto = new SundayCommunityDataDto(memberId,SundayCommunityDynamic.class.getName(),type,memberIds,null);
            model.addAttribute("dataDto",dataDto);
            if(type == SundayCommonConstants.community_dynamic_circle){//1.微信圈
                return "/aigou/weixin/community/circle/index";
            }else if(type == SundayCommonConstants.community_dynamic_tryout){//2.达人试用
                return "/aigou/weixin/community/tryout/index";
            }else if(type == SundayCommonConstants.community_dynamic_aigou){//3.本地爱购
                return "/aigou/weixin/community/aigou/index";
            }else if(type == SundayCommonConstants.community_dynamic_special){//4.特别关注
                return "/aigou/weixin/community/special/index";
            }
            return "/aigou/weixin/error";
        }catch (Exception e){
            logger.error("/sunday/weixin/community/index----e="+e.getMessage());
            e.printStackTrace();
            return "/aigou/weixin/error";
        }
    }


    @RequestMapping(value="/select", method= RequestMethod.POST)
    @ApiOperation("【微信端】获取分页数据:微信圈/本地爱购/达人试用/特别关注")
    public String select(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model,
            @ApiParam(required=false, name="memberIds", value="用户id集合,例如:memberIds=1,2,3,4...")@RequestParam(value = "memberIds", required = false)List<Long> memberIds,
            @ApiParam(required=true, name="type", value="类别:1-微信圈,2-达人试用,3-本地爱购,4-特别关注")@RequestParam(value = "type", required = true)Integer type,
            @ApiParam(required=false, name="memberId", value="用户id")@RequestParam(value = "memberId", required = false)Long memberId){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            List<SundayCommunityDynamicDto> list = communityDynamicService.select(type,memberIds,memberId,request);
            SundayCommunityDataDto dataDto = new SundayCommunityDataDto(memberId,SundayCommunityDynamic.class.getName(),type,null,list);
            model.addAttribute("dataDto",dataDto);
            if(type == SundayCommonConstants.community_dynamic_circle){//微信圈
                return "/aigou/weixin/community/circle/data";
            }else if(type == SundayCommonConstants.community_dynamic_tryout){//达人试用
                return "/aigou/weixin/community/tryout/data";
            }else if(type == SundayCommonConstants.community_dynamic_aigou){//本地爱购
                return "/aigou/weixin/community/aigou/data";
            }else if(type == SundayCommonConstants.community_dynamic_special){//特别关注
                return "/aigou/weixin/community/special/data";
            }
            return null;
        }catch (Exception e){
            logger.error("/sunday/weixin/community/select----e="+e.getMessage());
            e.printStackTrace();
            return null;
        }
    }

    @RequestMapping(value="/save", method= RequestMethod.POST)
    @ApiOperation(value="【微信端】保存:微信圈/本地爱购")
    public void save(HttpServletRequest request,
                     @ApiParam(required=true, name="memberId", value="用户id")@RequestParam(value = "memberId", required = true)Long memberId,
                     @ApiParam(required=true, name="type", value="类别:1-微信圈,3-本地爱购")@RequestParam(value = "type", required = true)Integer type,
                     @ApiParam(required=true, name="productIds", value="产品ids")@RequestParam(value = "productIds", required = true)List<Long> productIds){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            communityDynamicService.save(memberId,type,productIds,null);
            ResponseMessage.success();
        }catch (Exception e){
            String msg = CommonConstants.ERROMSG;
            Integer code= CommonConstants.FAIL_CODE;
            //自定义异常（签名错误）
            if(e.getClass().getSimpleName().equalsIgnoreCase("ErrorException")){
                msg=e.getMessage();
                //token已过期
            }else  if(e.getClass().getSimpleName().equalsIgnoreCase("TokenException")){
                code= CommonConstants.TOKEN_CODE;
                msg= CommonConstants.TOKENMSG;
            }else{
                logger.error("/sunday/weixin/community/save----e="+e.getMessage());
            }
            e.printStackTrace();
            ResponseMessage.error(code,msg);
        }
    }

    @RequestMapping(value="/saveTryout", method= RequestMethod.POST)
    @ApiOperation(value="【微信端】保存:达人试用")
    public void saveTryout(HttpServletRequest request,
                     @ApiParam(required=true, name="memberId", value="用户id")@RequestParam(value = "memberId", required = true)Long memberId,
                     @ApiParam(required=true, name="productIds", value="产品ids")@RequestParam(value = "productIds", required = true)List<Long> productIds,
                     @ApiParam(required=true, name="image", value="试用图片,多个图片以,号分隔")@RequestParam(value = "image", required = true)String image,
                     @ApiParam(required=true, name="content", value="试用内容")@RequestParam(value = "content", required = true)String content){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            communityDynamicService.save(memberId,productIds,image,content);
            ResponseMessage.success();
        }catch (Exception e){
            String msg = CommonConstants.ERROMSG;
            Integer code= CommonConstants.FAIL_CODE;
            //自定义异常（签名错误）
            if(e.getClass().getSimpleName().equalsIgnoreCase("ErrorException")){
                msg=e.getMessage();
                //token已过期
            }else  if(e.getClass().getSimpleName().equalsIgnoreCase("TokenException")){
                code= CommonConstants.TOKEN_CODE;
                msg= CommonConstants.TOKENMSG;
            }else{
                logger.error("/sunday/weixin/community/saveTryout----e="+e.getMessage());
            }
            e.printStackTrace();
            ResponseMessage.error(code,msg);
        }
    }

    */
/**
     * 试用详情
     * @param request
     * @param model
     * @param id    试用id
     * @param memberId  登录用户id
     * @return
     *//*

    @RequestMapping(value="/detail", method= RequestMethod.GET)
    public String tryoutDetail(HttpServletRequest request,Model model,
                               @RequestParam(value = "id", required = true)Long id,
                               @RequestParam(value = "memberId", required = true)Long memberId){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            SundayCommunityDynamicDto data = communityDynamicService.getDetailDto(id,memberId);
            model.addAttribute("data",data);
            model.addAttribute("className",SundayCommunityDynamic.class.getName());
            model.addAttribute("memberId",memberId);
            return "/aigou/weixin/community/detail";
        }catch (Exception e){
            logger.error("/sunday/weixin/community/detail----e="+e.getMessage());
            e.printStackTrace();
            return "/aigou/weixin/error";
        }
    }

    @RequestMapping(value="/comment/select", method= RequestMethod.POST)
    @ApiOperation(value="【微信端】获取评论分页数据")
    public String selectComment(
            HttpServletRequest request,Model model,
            @ApiParam(required=true, name="id", value="id")@RequestParam(value = "id", required = true)Long id,
            @ApiParam(required=true, name="className", value="实体名称")@RequestParam(value = "className", required = true)String className){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            List<SundayCommentDto> commentDtoList = commentService.selectComment(id,className,request);
            model.addAttribute("commentDtoList",commentDtoList);
            return "/aigou/weixin/community/comment/data";
        }catch (Exception e){
            logger.error("/sunday/weixin/community/comment/select----e="+e.getMessage());
            e.printStackTrace();
            return null;
        }
    }

    @RequestMapping(value="/goPraise", method= RequestMethod.POST)
    @ApiOperation(value="【微信端】点赞")
    public void goPraise(HttpServletRequest request,
                         @ApiParam(required=true, name="memberId", value="用户id")@RequestParam(value = "memberId", required = true)Long memberId,
                         @ApiParam(required=true, name="mainId", value="实体id")@RequestParam(value = "mainId", required = true)Long mainId,
                         @ApiParam(required=true, name="className", value="实体名称")@RequestParam(value = "className", required = true)String className){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            Long praisePoint = praiseRecordService.save(memberId, className,mainId);
            ResponseMessage.success(praisePoint);
        }catch (Exception e){
            String msg = CommonConstants.ERROMSG;
            Integer code= CommonConstants.FAIL_CODE;
            //自定义异常（签名错误）
            if(e.getClass().getSimpleName().equalsIgnoreCase("ErrorException")){
                msg=e.getMessage();
                //token已过期
            }else  if(e.getClass().getSimpleName().equalsIgnoreCase("TokenException")){
                code= CommonConstants.TOKEN_CODE;
                msg= CommonConstants.TOKENMSG;
            }else{
                logger.error("/sunday/weixin/community/goPraise----e="+e.getMessage());
            }
            e.printStackTrace();
            ResponseMessage.error(code,msg);
        }
    }

    @RequestMapping(value="/goComment", method= RequestMethod.POST)
    @ApiOperation(value="【微信端】评论")
    public void goComment(HttpServletRequest request,
                        @ApiParam(required=true, name="memberId", value="用户id")@RequestParam(value = "memberId", required = true)Long memberId,
                        @ApiParam(required=true, name="mainId", value="试用id")@RequestParam(value = "mainId", required = true)Long mainId,
                        @ApiParam(required=true, name="content", value="评论内容")@RequestParam(value = "content", required = true)String content,
                        @ApiParam(required=true, name="className", value="实体名称")@RequestParam(value = "className", required = true)String className){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            commentService.saveComment(memberId,mainId,content,className);
            ResponseMessage.success();
        }catch (Exception e){
            String msg = CommonConstants.ERROMSG;
            Integer code= CommonConstants.FAIL_CODE;
            //自定义异常（签名错误）
            if(e.getClass().getSimpleName().equalsIgnoreCase("ErrorException")){
                msg=e.getMessage();
                //token已过期
            }else  if(e.getClass().getSimpleName().equalsIgnoreCase("TokenException")){
                code= CommonConstants.TOKEN_CODE;
                msg= CommonConstants.TOKENMSG;
            }else{
                logger.error("/sunday/weixin/community/goComment----e="+e.getMessage());
            }
            e.printStackTrace();
            ResponseMessage.error(code,msg);
        }
    }

    */
/**
     * 个人中心
     * @param request
     * @param model
     * @param memberId  用户id
     * @return
     *//*

    @RequestMapping(value = "/personal/index", method= RequestMethod.GET)
    public String personal(HttpServletRequest request,Model model,
                           @RequestParam(value = "memberId", required = true)Long memberId){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            SundayPersonalDto data = communityDynamicService.packagePersonalDtoSingle(memberId,request);
            model.addAttribute("data",data);
            return "/aigou/weixin/community/personal/index";
        }catch (Exception e){
            logger.error("/sunday/weixin/community/personal/index----e="+e.getMessage());
            e.printStackTrace();
            return "/aigou/weixin/error";
        }
    }

    @RequestMapping(value="/personal/select", method= RequestMethod.POST)
    @ApiOperation(value="【微信端】获取个人中心(关注/粉丝)分页数据")
    public String selectPersonal(
            HttpServletRequest request,Model model,
            @ApiParam(required=true, name="memberId", value="用户id")@RequestParam(value = "memberId", required = true)Long memberId){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            List<SundayCommunityDynamicDto> list = communityDynamicService.selectPersonal(memberId,request);
            SundayCommunityDataDto dataDto = new SundayCommunityDataDto(memberId,SundayCommunityDynamic.class.getName(),null,null,list);
            model.addAttribute("dataDto",dataDto);
            return "/aigou/weixin/community/personal/data";
        }catch (Exception e){
            logger.error("/sunday/weixin/community/personal/select----e="+e.getMessage());
            e.printStackTrace();
            return null;
        }
    }
}
*/
